<template>
  <div class="myContainer">        
     <el-row class="myTitleBorderBottom">
      <el-col :span="20" class="myLineHeight_40px">
        访客信息
      </el-col>
    </el-row>
    <el-form :model="detail" :rules="rules" ref="ruleForm">    	
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         访客姓名:
      </el-col>
      <el-col :span="7">        
            <el-input :readonly="is_modifly" v-model="visitor_name" placeholder="请输入访客姓名"></el-input>          
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         联系电话:
      </el-col>
      <el-col :span="7">      	
           <el-input placeholder="请输入联系电话" v-model="visitor_phone" :readonly="is_modifly"></el-input>        
      </el-col>
    </el-row>
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
      	
           开始有效时间:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="create_time"
          :disabled="is_modifly"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="请选择开始有效时间">
        </el-date-picker>  
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
      	
        结束有效时间:
      </el-col>
      <el-col :span="7">
        <el-date-picker
          v-model="end_valid_date"
          :disabled="is_modifly"
          type="date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          placeholder="请选择结束有效时间">
        </el-date-picker>  
      </el-col>
    </el-row>   
    <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          拜访单位信息
        </el-col>
      </el-row>
    
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         小区:
      </el-col>
     <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="area_name" placeholder="请输入小区"></el-input>          
      </el-col>
    </el-row>
     <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         业主姓名:
      </el-col>
      <el-col :span="7">     
            <el-input :readonly="is_modifly" v-model="person_id" placeholder="请输入业主姓名"></el-input>          
      </el-col>
    </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         联系电话:
      </el-col>
      <el-col :span="7">      
            <el-input :readonly="is_modifly" v-model="card_no" placeholder="请输入联系电话"></el-input>          
      </el-col>
    </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         房屋信息:
      </el-col>
      <el-col :span="7">      
            <el-input :readonly="is_modifly" v-model="room_addr" placeholder="请输入房屋信息"></el-input>         
      </el-col>
    </el-row>
      <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          状态及备注
        </el-col>
      </el-row>
       <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">      	
         平台同步状态:
      </el-col>
      <el-col :span="7">
        <template>
          <el-select 
            v-model="sync_status"
            :disabled="is_modifly"
            clearable
            placeholder="请选择升级状态">
            <el-option
              v-for="item in syncStatusList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-col>
    </el-row> 
         <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         备注:
      </el-col>
      <el-col :span="7">      
            <el-input :readonly="is_modifly" v-model="extra_desc" type="textarea" placeholder="请输入备注"></el-input>         
      </el-col>
    </el-row>
     <el-row class="myTitleBorderBottom myMarginTop_10px">
        <el-col :span="20" class="myLineHeight_40px">
          访客通行权限
        </el-col>
      </el-row>
        <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         通行区域:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="access_area_ids" type="textarea" placeholder="请输入通行区域"></el-input>          
      </el-col>
    </el-row>
         <el-row class="myMarginTop_10px">
      <el-col :span="3" class="myLeftMsg">
        
         人员通行规则:
      </el-col>
      <el-col :span="7">       
            <el-input :readonly="is_modifly" v-model="person_id" placeholder="请输入人员通行规则"></el-input>         
      </el-col>
    </el-row>        
    <el-row class="myMarginTop_10px">
      <el-col :span="7" :offset="3">        
        <!--<el-button type="primary" class="myBgGreen" @click="onCreate">权限下放</el-button>
        <el-button type="primary" class="myBgGreen" @click="">取消授权</el-button>-->
        <el-button type="primary" class="myBgGreen" @click="onBack">返 回</el-button>        
      </el-col>
    </el-row>
  </el-form>  
    
  </div>
</template>
<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myLeftMsg{
    line-height: 40px;
    text-align: right;
    padding-right: 10px;
  }
  .myMarginTop_10px{
    padding-bottom: 10px;
  }
  .myVA_M{
    vertical-align: middle;
  }
  .myMarginBottom_10px{
    margin-bottom: 20px;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
    border:1px solid #d8dce5;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>

<script>
  import { getJumpValue , addAd , getAd , editAd } from '@/api/online';
  import { getGuestDetail } from '@/api/entrance_guard';
  import { r_email , r_phone } from "@/api/regular";//正则
  export default {
    data(){
      return{
        title: "访客管理",
        id: "",
        is_modifly:false,
        type:"",
        ad_name:"",
         detail:{
          
        },                   
        ad_jumpValue:"",
            
        ADDESC:"",
        visitor_name:"",
        access_area_ids:"",
        extra_desc:"",
        sync_status:"",
        room_addr:"",
        card_no:"",
        area_name:"",
        end_valid_date:"",
        create_time:"",
        visitor_phone:"",
        person_id:"",
        syncStatusList:[{value:1,label:"已同步"},{value:2,label:"未同步"}],
        rules: {
                  card_no:[ {required: true, message: '不能为空！', trigger: 'blur'},],                                                                
          },
      }
    },
    components: {
        
    },
    created(){
      document.title=this.title;
      this.type = this.$route.query.type;
      this.id = this.$route.query.id;
      if(this.type=='add'){
      }
      if(this.type=='info'){
        this.onGetAd();
        this.is_modifly = true;
        this.is_disabled = true;
      }
      
    },
    methods:{     
      onEditAd(){
        let vm=this;
        let params={          
          ADDESC:vm.ADDESC,
         
        }
        editAd(params).then(response => {
          console.log("修改成功")
          this.$message.success('执行成功！');
          this.$router.go(-1);
        }).catch(error => {
          this.$message.error('执行失败！');
          console.log("修改失败")
        })
      },
      onCreate(){//添加
        let vm=this;
        let params={
        
          ADDESC:vm.ADDESC,
        }
        addAd(params).then(response => {
          let res=response.data;
          vm.$message.success("添加数据成功！");
          this.$router.go(-1);
          console.log("添加成功",res);
        }).catch(error => {
          vm.$message.error("添加数据失败！");
          console.log("添加失败",error);
        })
        console.log(params)
      },
      onBack(){//返回
      	let vm =this;
      	window.localStorage.setItem('pageNum',vm.$route.query.pageNum||1);
        this.$router.go(-1);
      },
      
      onGetAd(){//拉取
        let vm=this;       
        getGuestDetail(vm.id).then(response => {
          let res=response.data;
          vm.visitor_name=res.visitor_name;
          vm.access_area_ids=res.access_area_ids;
          vm.extra_desc=res.extra_desc;
          vm.sync_status=res.sync_status;
          vm.room_addr=res.room_addr;
          vm.card_no=res.card_no;
          vm.area_name=res.area_name;
          vm.end_valid_date=res.end_valid_date;
          vm.create_time=res.create_time;
          vm.visitor_phone=res.visitor_phone;
        }).catch(error => {
          console.log("拉取数据失败",error);
        })
      } 
      

    }
  
  }


</script>



